package org.dromara.system.controller;

import cn.hutool.core.lang.tree.Tree;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.base.R;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.service.ISysDeptService;
import org.dromara.system.service.SysDeptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName EY-SysDeptController
 * @Description org.dromara.system.controller
 * @Author menyj
 * @Date 2025/9/20
 **/
@RestController
public class SysDeptController {

    @Autowired
    private ISysDeptService iSysDeptService;

    @Autowired
    private SysDeptServiceImpl sysDeptServiceImpl;

    @GetMapping("/list")
    public R<List<SysDeptVo>> list(SysDeptBo dept) {
        List<SysDeptVo> depts = iSysDeptService.selectDeptList(dept);
        return R.ok(depts);
    }

    @GetMapping("/list2")
    public R<List<SysDept>> list2(SysDeptBo dept) {
        List<SysDept> depts = sysDeptServiceImpl.list();
        return R.ok(depts);
    }

    @GetMapping("/tree/list")
    public R<List<Tree<Long>>>  selectDeptTreeList(SysDeptBo dept) {
        List<Tree<Long>> depts = iSysDeptService.selectDeptTreeList(dept);
        return R.ok(depts);
    }
}
